//
//  StrategyCell.m
//  Full_House
//
//  Created by 张忱 on 15-6-3.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "StrategyCell.h"
#import "StrategyDetailViewController.h"


@implementation StrategyCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.titleLable = [[UILabel alloc] init];
        
        [self.contentView addSubview:self.titleLable];
        [_titleLable release];
        
        self.introduceLable = [[UILabel alloc] init];
        [self.contentView addSubview:self.introduceLable];
        [_introduceLable release];
        
        self.stylistLable = [[UILabel alloc] init];
        [self.contentView addSubview:self.stylistLable];
        [_stylistLable release];
        
        self.dataLable = [[UILabel alloc] init];
        [self.contentView addSubview:self.dataLable];
        [_dataLable release];
        
        self.strategyImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.strategyImageView];
        self.strategyImageView.backgroundColor = [UIColor yellowColor];
        [_strategyImageView release];
        
        
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat width = self.contentView.frame.size.width / 2;
    CGFloat height = self.contentView.frame.size.height / 4;
    
    self.strategyImageView.frame = CGRectMake(10, 10, width - 20, height * 4 - 20);
    self.titleLable.frame = CGRectMake(width, 10, width, height);
    self.introduceLable.frame = CGRectMake(width, height, width, height * 2);
    self.stylistLable.frame = CGRectMake(width, height * 3 - 10, width / 2, height);
    self.dataLable.frame = CGRectMake(width * 3 / 2, height * 3 - 10, width / 2, height);
    
    
}

- (void)setStrategy:(Strategy *)strategy
{
    if (_strategy != strategy) {
        [_strategy release];
        _strategy = [strategy retain];
    }
    self.titleLable.text = strategy.title;
    self.introduceLable.text = strategy.des;
    self.dataLable.text = [strategy.date substringWithRange:NSMakeRange(0, 10)];
    self.stylistLable.text = strategy.userName;
    
    //self.sdetailID = strategy.detailID;
    NSLog(@"0.0.0.0%@", strategy.detailID);
    
    
    
    
    NSURL *urlImage = [NSURL URLWithString:strategy.image];
    
    
    [self.strategyImageView setImageWithURL:urlImage];
//    NSLog(@"%@", strategy.userName);
    
    
}




- (void)dealloc
{
    [_strategyImageView release];
    [_titleLable release];
    [_introduceLable release];
    [_dataLable release];
    [_stylistLable release];
    [super dealloc];
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
